-- 公会成员战功榜
local GuildWarMemberScoreTabPanel = app.mvc.createPanelClass(...)
local ListViewVertical = require("app.widget.listview.ListViewVertical")
local GuildWarMemberScoreCell = import("..renders.GuildWarMemberScoreCell")
--data =
function GuildWarMemberScoreTabPanel.createWithData(data, node)
    local sprite = GuildWarMemberScoreTabPanel.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end

function GuildWarMemberScoreTabPanel.create(node)
    return GuildWarMemberScoreTabPanel.createWithData(nil, node)
end

function GuildWarMemberScoreTabPanel:init(data)
    self.super.init(self, data)
    local params = {
        renderClass = GuildWarMemberScoreCell,   
    }
    self._listview = ListViewVertical.new(self._ui["Panel/ScrollView"], params)
    self:registerViewEvent({
        {name = ViewEvent.CSGuildWar_MemberInfo, callback = handler(self, self._onGetMemberInfo)},
    })
    self._memberData = {}
    
end


function GuildWarMemberScoreTabPanel:onTabSelect()
    UD.csGuildWarData:C2S_WorldGuildWarMemberRank()
end

function GuildWarMemberScoreTabPanel:_onGetMemberInfo(eventName, datas)
    self._memberData = datas or {}
    self:refresh()
end

function GuildWarMemberScoreTabPanel:refresh()
    self._listview:reloadData(self._memberData)
    self._ui["Panel/Panel_tips"]:setVisible(#self._memberData == 0)
end

function GuildWarMemberScoreTabPanel:setPanelTabIndex(index)
    self._tabPanelIndex = index
end

-- -- 测试数据代码
-- function GuildWarMemberScoreTabPanel:getTestData()
--     local data = {}
--     for i = 1, 10 do
--         table.insert( data, {})
--     end
--     return data
-- end


return GuildWarMemberScoreTabPanel